package com.clive.xxweb.vo;


import com.clive.xxweb.constant.DishConstant;

import java.util.HashMap;
import java.util.Map;

public class DishResult {
    private String message;
    private Integer code;
    private boolean success;
    private Map<String,Object> data = new HashMap<String,Object>();

    public static DishResult ok(){
        DishResult result = new DishResult();
        result.setMessage("成功");
        result.setCode(DishConstant.SUCCESS);
        result.setSuccess(true);
        return result;
    }
    public static DishResult error(String message){
        DishResult result = new DishResult();
        result.setMessage(message);
        result.setCode(DishConstant.ERROR);
        result.setSuccess(false);
        return result;
    }
    //    默认map集合里面没有值
    public DishResult data(String key,Object value){
//        往map集合里面添加数据  返回一个集合  返回的结果集可以添加多个对象
        this.data.put(key,value);
        return this;
    }
    //    方法的重载   为什么要重载
    public DishResult data(Map<String,Object> map){
        this.data(map);
        return this;
    }
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public Map<String, Object> getDate() {
        return data;
    }

    public void setDate(Map<String, Object> date) {
        this.data = date;
    }

    @Override
    public String toString() {
        return "DishResult{" +
                "message='" + message + '\'' +
                ", code=" + code +
                ", success=" + success +
                ", date=" + data +
                '}';
    }
}